package Panels;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.sql.ResultSet;
import java.util.StringTokenizer;

import javax.swing.JButton;
import javax.swing.JComboBox;

import componentes.ConexionBD;
import componentes.Ficha;
import componentes.labtext;
import componentes.panelconfondo;

public class PanelSProvpelis extends panelconfondo implements ActionListener {
	GridBagConstraints gbc;
	JButton bcontinuar,breset;
	int panel;
	JComboBox combo;
	String consulta;
	StringTokenizer elementos;
	String numemp;
	
public PanelSProvpelis(){
	super.setimagen("/recursos/cine1.jpg");
	panel = 1;
	consulta = new String ("Select NIF , nombre from provpelis");
	cargaproveedores();
	this.dibujar();
	
	
}

	

	private void cargaproveedores() {
	// TODO Auto-generated method stub
		System.out.println(consulta);
		
		combo = new JComboBox();
		combo.setPreferredSize(new Dimension(130, 20)); 

		try {
			ResultSet rs = ConexionBD.executeQuery(consulta);
			while(rs.next()){
		    	combo.addItem(rs.getString(1)+","+rs.getString(2));
		    }
		}catch(Exception e){
			e.printStackTrace();
		}
		
		
}



	public void actionPerformed(ActionEvent e) {
		String cine = combo.getSelectedItem()+"";
		elementos = new StringTokenizer(cine,",");
		cine = elementos.nextToken();  
		String codpost = elementos.nextToken();
	
		new Ficha("ProvPelis",new PanelGProveedor(cine),"edita los datos de un proveedor");
	
		
	}

public void dibujar(){
this.setLayout(new GridBagLayout());
	
    gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0,
			GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(
					5, 5, 5, 5), 0, 0);
	this.add(combo,gbc);
	bcontinuar = new JButton("Seleccionar");
	gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0,
			GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(
					5, 5, 5, 5), 0, 0);
	bcontinuar.addActionListener(this);
	this.add(bcontinuar,gbc);
	

}
	
	
	
}